[Solved] Gatsby Command Error

Gatsby로 dev blog를 다시 운영하기 위해 install하면서 생긴 에러를 해결한 과정에 대한 기록

에러 👾

개츠비 hot fix 사용 중에 gatsby command가 전부 먹통이됨


  • node module 중 gatsby-cli와 gatsby를 전부 삭제하고

    ls -g|grep으로 클린하게 삭제되었는지를 확인

    npm ls -g|grep gatsby

    터미널이 아무것도 리턴하지 않으면 성공!🎉


  • 개츠비에서 시키는 대로 gatsby-cli를 install

    npm install -g gatsby-cli

  • 새로운 프로젝트 생성 → 에러발생 (이미 가지고 있는 개츠비 프로젝트에 develop, build, help 등 다른 command 입력해도 같은 에러가 발생했음)

    gatsby new
    ~/Desktop   44s
    ❯ gatsby new
    /usr/local/lib/node_modules/gatsby-cli/node_modules/uuid/dist/esm-browser/index.js:1
    export { default as v1 } from './v1.js';
    ^^^^^^
    
    SyntaxError: Unexpected token 'export'
        at wrapSafe (internal/modules/cjs/loader.js:1060:16)
        at Module._compile (internal/modules/cjs/loader.js:1108:27)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
        at Module.load (internal/modules/cjs/loader.js:993:32)
        at Function.Module._load (internal/modules/cjs/loader.js:892:14)
        at Module.require (internal/modules/cjs/loader.js:1033:19)
        at require (internal/modules/cjs/helpers.js:72:18)
        at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/telemetry.js:8:13)
        at Module._compile (internal/modules/cjs/loader.js:1144:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)

    → node module 중에 uuid가 뭔가 문제가 있는 것 같아 보였음



시도 🤖

구글링 키워드 : uuid/dist/esm-browser/index.js:1


uuidjs는 홀수버전 node를 지원하지 않음 띠용때용


This is a problem in the https://github.com/uuidjs/uuid/ package where they don’t support odd Node versions https://github.com/uuidjs/uuid/issues/466 .

Upgrade your Node version. I’m now on 14.4.0 and it works fine.

1



해결 🛠

nvm install v14.4
nvm use 14.4
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
Run `npm config delete prefix` or `nvm use --delete-prefix v14.4.0` to unset it.
npm config delete prefix
~/Desktop
❯ nvm use 14.4
Now using node v14.4.0 (npm v6.14.5)

~/Desktop
❯ node -v
v14.4.0
npm install -g gatsby-cli
gatsby new

→ 잘 작동!




reference

Unexpected token ‘export’ in Sequelize UUID


ABOUT ME
I write codes and words.
제가 궁금하다면 ABOUT ME 버튼을 눌러보세요!

GitHubLinkedIn